<template>
  <div class="page-container">
    <SearchPanel @change="handleSearchPanelChange">
      <el-form
        ref="queryForm"
        class="query-more-form"
        size="mini"
        label-width="100px"
        :model="query"
      >
        <el-row :gutter="20">
          <el-col :span="5">
            <el-form-item label="事项名称">
              <el-input
                v-model="query.itemName"
                class="search-ipt"
                placeholder="请输入事项名称"
                maxlength="255"
              />
            </el-form-item>
          </el-col>
          <el-col :span="5">
            <el-form-item label="行业">
              <el-input
                v-model="query.industryName"
                class="search-ipt"
                placeholder="请输入行业"
                maxlength="255"
              /> </el-form-item
          ></el-col>
          <el-col :span="5">
            <el-form-item label="检查类型">
              <el-select
                class="w-100"
                v-model="query.typeName"
                placeholder="请选择检查类型"
                clearable
              >
                <el-option
                  v-for="item in typeNames"
                  :key="item.code"
                  :value="item.typeName"
                  :label="item.typeName"
                />
              </el-select>
            </el-form-item>
          </el-col>

          <el-col :span="5">
            <el-form-item label="主体类型">
              <el-select
                class="w-100"
                v-model="query.level"
                placeholder="请选择主体类型"
                clearable
                ><el-option
                  v-for="item in options"
                  :key="item.value"
                  :label="item.label"
                  :value="item.value"
                >
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="2" class="btn-col"
            ><el-button size="mini" class="search-btn" @click="select"
              >查询</el-button
            ></el-col
          >
        </el-row>
      </el-form>
    </SearchPanel>
    <div class="table-container">
      <div class="table-tools-panel table-flex-row">
        <el-button class="flush-btn" size="mini" icon="el-icon-refresh"
          >刷新</el-button
        >
        <div>
          <el-button
            class="tools-btn"
            size="mini"
            icon="el-icon-set-up"
          ></el-button>
          <el-button
            class="tools-btn"
            size="mini"
            icon="el-icon-share"
          ></el-button>
          <el-button
            class="tools-btn"
            size="mini"
            icon="el-icon-printer"
          ></el-button>
        </div>
      </div>
      <div class="table-list-panel">
        <el-table
          v-loading="tableLoading"
          border
          size="small"
          :data="tableData"
          :height="isShow ? 'calc(100vh - 410px)' : 'calc(100vh - 335px)'"
          style="width: 100%"
        >
          <el-table-column type="selection" width="45" />
          <el-table-column prop="id" label="ID序号" show-overflow-tooltip />
          <el-table-column
            prop="itemName"
            label="事项名称"
            show-overflow-tooltip
          />
          <el-table-column prop="level" label="所属行业" show-overflow-tooltip>
            <template slot-scope="scope">
              <template v-if="scope.row.level == 1">
                <span>建筑局</span>
              </template>
              <template v-if="scope.row.level == 2">
                <span>国土局</span>
              </template>
              <template v-if="scope.row.level == 3">
                <span>消防局</span>
              </template>
            </template>
          </el-table-column>
          <el-table-column
            prop="basis"
            label="法律依据"
            show-overflow-tooltip
          />
          <el-table-column
            prop="itemName"
            label="监管部门"
            show-overflow-tooltip
          />
          <el-table-column
            prop="disposalStandards"
            label="处置标准"
            show-overflow-tooltip
          />
          <el-table-column
            prop="specificBehavior"
            label="考核标准"
            show-overflow-tooltip
          />
          <el-table-column
            prop="pname"
            label="检查类型"
            show-overflow-tooltip
          />
          <el-table-column
            prop="frequency"
            label="检查频率"
            show-overflow-tooltip
          />
          <el-table-column
            prop="frequencyType"
            label="检查频次"
            show-overflow-tooltip
          />
          <el-table-column label="操作" width="160" fixed="right">
            <template>
              <el-button
                class="table-inner-btn"
                type="text"
                size="mini"
                @click="showpopup"
                >详情</el-button
              >
            </template>
          </el-table-column>
        </el-table>
      </div>
      <div class="pagination-panel">
        <Pagination
          :total="query.total"
          :page.sync="query.pageNum"
          :limit.sync="query.pageSize"
          @pagination="initData"
        />
      </div>
    </div>
    <patrol-dialog
      :dialogVisible="dialogVisible"
      @closeDialog="dialogVisible = false"
    />
  </div>
</template>

<script>
import SearchPanel from "@/components/SearchPanel";
import Pagination from "@/components/Pagination";
import { getList } from "@/api/system/matters";
import patrolDialog from "./components/patrolDialog.vue";

export default {
  name: "CaseDealDispatch",
  components: {
    SearchPanel,
    Pagination,
    patrolDialog,
  },
  data() {
    return {
      // 1 行业 2 监管类型 3事项
      options: [
        {
          value: "1",
          label: "行业",
        },
        {
          value: "2",
          label: "监管类型",
        },
        {
          value: "3",
          label: "事项",
        },
      ],
      query: {
        pageNum: 1,
        page: 2,
        pageSize: 10,
      },
      tableLoading: false,
      tableData: [],
      typeNames: [],
      isShow: true,
      dialogVisible: false,
    };
  },
  created() {
    this.initData();

    getList().then((response) => {
      this.typeNames = response.rows;
    });
  },
  methods: {
    handleSearchPanelChange(flag) {
      this.isShow = flag;
    },
    initData() {
      this.select();
    },
    select() {
      this.tableLoading = true;
      getList(this.query)
        .then((result) => {
          this.tableLoading = false;
          this.query.total = result.total;
          this.tableData = result.rows;
        })
        .catch(() => {
          this.tableLoading = false;
        });
    },
    showpopup() {
      this.dialogVisible = true;
    },
  },
};
</script>

<style lang="scss" scoped>
</style>